<template>
  <a-modal
    :title="title"
    :width="width"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
        <div>
            <a-row class="form-row" :gutter="24">
              <a-col :lg="8">
                <a-form-item label="合同名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'fxy02', validatorRules.fxy02]" placeholder="请输入合同名称"></a-input>
        </a-form-item>
              </a-col>
              
              <a-col :lg="8">
                <a-form-item label="附件名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'fxy03', validatorRules.fxy03]" placeholder="请输入附件名称"></a-input>
        </a-form-item>
              </a-col>
              <a-col :lg="8">
                <!--<a-form-item label="合同地址" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
                  <a-form-item label="合同附件" :labelCol="labelCol" :wrapperCol="wrapperCol">
                    <j-upload v-decorator="['fxy04', validatorRules.fxy04]" :trigger-change="true"></j-upload>
                  </a-form-item>
          <!--<a-input v-decorator="[ 'fxy04', validatorRules.fxy04]" placeholder="请输入合同地址"></a-input>-->
        <!--</a-form-item>-->
              </a-col>
              <a-col :lg="8">
                <a-form-item label="案件编号" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'fxy05', validatorRules.fxy05]" placeholder="请输入案件编号"></a-input>
        </a-form-item>
              </a-col>
              <a-col :lg="8">
                <a-form-item label="批次编号" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'fxy06', validatorRules.fxy06]" placeholder="请输入批次编号"></a-input>
        </a-form-item>
              </a-col>
            </a-row>

        </div>

        <!-- <a-form-item label="外键" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'fxy01', validatorRules.fxy01]" placeholder="请输入外键"></a-input>
        </a-form-item> -->
        
        
        
        
        
        <!-- <a-form-item label="备注1" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'fxy07', validatorRules.fxy07]" placeholder="请输入备注1"></a-input>
        </a-form-item>
        <a-form-item label="备注2" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'fxy08', validatorRules.fxy08]" placeholder="请输入备注2"></a-input>
        </a-form-item>
        <a-form-item label="备注3" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'fxy09', validatorRules.fxy09]" placeholder="请输入备注3"></a-input>
        </a-form-item>
        <a-form-item label="备注4" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'fxy10', validatorRules.fxy10]" placeholder="请输入备注4"></a-input>
        </a-form-item> -->

      </a-form>
    </a-spin>
  </a-modal>
</template>

<script>

  import { httpAction } from '@/api/manage'
  import pick from 'lodash.pick'
  import JUpload from '@/components/jeecg/JUpload'
  export default {
    name: "FxyConcact02Modal",
    components: {
      JUpload

    },
    props:{
      mainId:{
        type:String,
        required:false,
        default:''
      }
    },
    data () {
      return {
        form: this.$form.createForm(this),
        title:"操作",
        width:1400,
        visible: false,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },

        confirmLoading: false,
        validatorRules:{
        fxy01:{},
        fxy02:{},
        fxy03:{},
        fxy04:{},
        fxy05:{},
        fxy06:{},
        fxy07:{},
        fxy08:{},
        fxy09:{},
        fxy10:{},
        },
        url: {
          add: "/gzgl01/fxyConcact/addFxyConcact02",
          edit: "/gzgl01/fxyConcact/editFxyConcact02",
        }

      }
    },
    created () {
    },
    methods: {
      add () {
        this.edit({});
      },
      edit (record) {
        this.form.resetFields();
        this.model = Object.assign({}, record);
        this.visible = true;
        this.$nextTick(() => {
          this.form.setFieldsValue(pick(this.model,'createBy','createTime','updateBy','updateTime','sysOrgCode','fxy01','fxy02','fxy03','fxy04','fxy05','fxy06','fxy07','fxy08','fxy09','fxy10'))
        })
      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      handleOk () {
        const that = this;
        // 触发表单验证
        this.form.validateFields((err, values) => {
          if (!err) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            let formData = Object.assign(this.model, values);
            formData['fxy01'] = this.mainId
            console.log("表单提交数据",formData)
            httpAction(httpurl,formData,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              that.close();
            })
          }

        })
      },
      handleCancel () {
        this.close()
      },
      popupCallback(row){
        this.form.setFieldsValue(pick(row,'createBy','createTime','updateBy','updateTime','sysOrgCode','fxy01','fxy02','fxy03','fxy04','fxy05','fxy06','fxy07','fxy08','fxy09','fxy10'))
      },


    }
  }
</script>
